<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- 
$nextTick:setTimeout高级版本，它是一个异步处理，相当于计算好了在它前面数据渲染到页面所需要时间后进行调用
用法： this.$nextTick(()=>{
    //它前面数据渲染完成后再调用
    })

 -->
      <p ref="msg">{{msg}}</p>
      <br />
      <button @click="btnClick">点我啊</button>
      <br />
      <img :src="imgSrc" alt="" v-if="bol" @click="refreshImg" />
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          msg: "这是一个寂寞的天",
          imgSrc: "http://127.0.0.1/heimamm/public/captcha?type=sendsms",
          bol: true,
        },
        methods: {
          btnClick() {
            this.msg = 123;
            // this.$nextTick(() => {
            //   window.console.log(this.msg);
            // });
            this.msg = 456;
          },
          refreshImg() {
            this.bol = false;
            this.$nextTick(() => {
              this.bol = true;
            });
            // setTimeout(() => {
            //   this.bol = true;
            // }, 100);
          },
        },
      });
    </script>
  </body>
</html>
